<?php

namespace server\dao;

use common\helpers\ConstantHelper;
use Yii;

/**
 * This is the model class for table "equ_line".
 *
 * @property int $id
 * @property string $name 名称
 * @property int $status 0:禁用，1:启用，-1:删除
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class EquLine extends \common\core\server\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'equ_line';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['status', 'created_at', 'updated_at'], 'integer'],
            [['name'], 'string', 'max' => 60],
            [['status'], 'default', 'value' => 1],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'status' => 'Status',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function getLineList()
    {
        return self::find()->where(['status' => ConstantHelper::NOT_DELETE])->asArray()->all();
    }

    public function getLineByIds($line_ids)
    {
        return self::find()->select('id,name,created_at,updated_at')->where(['in', 'id', $line_ids])->asArray()->all();
    }

    public function getLineByName($name){
        return  self::findOne(['name'=>$name,'status' => ConstantHelper::NOT_DELETE]);
    }
}
